<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="lsFn" uri="http://www.leedsoft.cn/functons" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>luma test</title>
    <style type="text/css">/*div布局。。。css控制*/
        *{margin: 0;padding: 0;}/*css init script*/
        div.main{background-color: beige; padding: 0 200px}
        div.header{height: 100px; background-color: aquamarine;}
        div.body{height: 850px; background-color: azure}
        div.footer{height: 50px; background-color: cadetblue}
        /*//jquery validate + jquery form + jquery jbox + bootstrap css组成快速构建前端页面工具集*/
    </style>
</head>
<body>
<div class="main">
    <div class="header">
        <h1>luma test</h1>
    </div>
    <div class="body">
        测试get：<br/>
        ${leeds}
        ${lsFn:toJsonString(T)}
        <hr/>
        测试to_ajax：<br/>
        <input type="button" value="testAjax" name="testAjax"/>
        <hr/>
        测试upload_file：<br/>
        <form action="${pageContext.request.contextPath}/test/upload_file" enctype="multipart/form-data" method="post">
            <input type="text" name="name"/>
            <input type="file" name="file"/>
            <input type="submit"/>
        </form>
        <hr/>
        测试download_file：<br/>
        <input type="button" value="testDownload" name="testDownload"/>
        <hr/>
        <form id="validForm" action="/test/valid_parameters/leedsoft">
            <input type="hidden" name="str" value="nana"/>
            <input type="hidden" name="intVal" value="12"/>
            <%--<input type="hidden" name="date" value="1467623201000"/>--%>
            <%--<input type="hidden" name="date" value="2016-07-04"/>--%>
            <input type="hidden" name="date" value="17:06:41"/>
            <input type="hidden" name="nickname" value="wc331111"/>
            <input type="hidden" name="id" value="333"/>
            <input type="button" value="valid-param" onclick="validParam()"/>
            <%--<input type="submit"/>--%>
        </form><br/>
        结果是：<span id="result"></span>
        <hr/>

        <div>
            <form action="/test/testAjaxForm" method="post" id="form1" enctype="multipart/form-data">
                <input type="file" name="files" multiple/>
                <input type="hidden" name="name1" value="22"/>
                <input type="submit" value="springmvc fileupload submit"/>
            </form>
            <br/>
            <form action="/servlet/commonsFileUpload" method="post" id="form2" enctype="multipart/form-data">
                <input type="file" name="files" multiple/>
                <input type="hidden" name="name1" value="22"/>
                <input type="submit" value="commons fileupload submit"/>
            </form>

        </div>
    </div>
    <div class="footer"></div>
</div>


<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/plugins/jquery/jquery.form.js"></script>
<script type="text/javascript">
    $(function () {
        $(document).on("click", "input[name=testAjax]", function () {
            $.ajax({
                url: "${pageContext.request.contextPath}/test/to_ajax",
                type: "POST",
                data: "",
                dataType: "json",
                success: function (res) {
                    alert(JSON.stringify(res));
                }
            });
        })

        $(document).on("click", "input[name=testDownload]", function () {
            location.href = "${pageContext.request.contextPath}/test/download_file";
        })

        $("#form1").ajaxForm({
            dataType: 'json',
            clearForm: true,
            success: function (res) {
                alert(JSON.stringify(res));
            }
        });
    });

    function validParam() {
        $.ajax({
            url: "${pageContext.request.contextPath}/test/valid_parameters/leedsoft",
            type: "GET",
            data: $('#validForm').serialize(),
            dataType: "json",
            success: function (res) {
                $('#result').html(JSON.stringify(res));
            }
        });
    }
</script>
</body>
</html>
